package com.ynny.dao;

import com.ynny.bean.Conurses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class ConursesDaoImpl implements IConursesDao {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Override
    public List<Conurses> selectAll() {
        String sql = "select * from courses";
        List<Conurses> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<Conurses>(Conurses.class));
        return query;
    }

    @Override
    public int updateConurses(Integer moive) {
        String sql = "update courses set moive = moive - ? ";
        int update = jdbcTemplate.update(sql, moive );
        return update;

    }
}
